//
//  PCDApiShowActionSheet.m
//  PCDMPaasBank
//
//  Created by DK on 2021/3/8.
//  Copyright © 2021 Alibaba. All rights reserved.
//

#import "PCDApiShowActionSheet.h"
#import "PCDMPActionSheet.h"

@implementation PCDApiShowActionSheet

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
      
    
    NSArray *itemList = [data objectForKey:@"itemList"];
    NSString *itemColor = [data objectForKey:@"itemColor"];
    NSString *callBack = [data objectForKey:@"success"];
    
    if ([PCDUtil nilOrEmptyString:itemColor]) {
        itemColor = @"#000000";
    }
    PCDMPActionSheet *sheet = [[PCDMPActionSheet alloc] initWithCancleTitle:@"取消" otherTitlesArray:itemList titleColor:itemColor];
    sheet.clickBlock = ^(PCDMPActionSheetItem * _Nonnull sheetItem) {
        NSDictionary *backDict = @{@"tapIndex":@(sheetItem.index-1)};
        if (![PCDUtil nilOrEmptyString:callBack]) {
            //
            evaluateJavaScriptOnMainThread(self,callBack,[backDict JSONRepresentation]);
        }
    };
    [sheet show];

}

@end
